<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>offlinestatuscard.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_offlinestatuscard.js.html">offlinestatuscard.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview A card that displays the offline status of an app. It contains
<a name="line17"></a> * detailed information such as a progress bar the indicates the status of
<a name="line18"></a> * syncing and allows you to perform actions (such as manually go offline).
<a name="line19"></a> *
<a name="line20"></a> * @see ../demos/offline.html
<a name="line21"></a> */
<a name="line22"></a>
<a name="line23"></a>goog.provide(&#39;goog.ui.OfflineStatusCard&#39;);
<a name="line24"></a>goog.provide(&#39;goog.ui.OfflineStatusCard.EventType&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.require(&#39;goog.dom&#39;);
<a name="line27"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line28"></a>goog.require(&#39;goog.gears.StatusType&#39;);
<a name="line29"></a>goog.require(&#39;goog.structs.Map&#39;);
<a name="line30"></a>goog.require(&#39;goog.style&#39;);
<a name="line31"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line32"></a>goog.require(&#39;goog.ui.Component.EventType&#39;);
<a name="line33"></a>goog.require(&#39;goog.ui.ProgressBar&#39;);
<a name="line34"></a>
<a name="line35"></a>
<a name="line36"></a>
<a name="line37"></a>/**
<a name="line38"></a> * A offline status card.
<a name="line39"></a> * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
<a name="line40"></a> * @constructor
<a name="line41"></a> * @extends {goog.ui.Component}
<a name="line42"></a> */
<a name="line43"></a>goog.ui.OfflineStatusCard = function(opt_domHelper) {
<a name="line44"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line45"></a>
<a name="line46"></a>  /**
<a name="line47"></a>   * The progress bar for showing the status of syncing.
<a name="line48"></a>   * @type {goog.ui.ProgressBar}
<a name="line49"></a>   * @private
<a name="line50"></a>   */
<a name="line51"></a>  this.progressBar_ = new goog.ui.ProgressBar(opt_domHelper);
<a name="line52"></a>  this.addChild(this.progressBar_);
<a name="line53"></a>
<a name="line54"></a>  /**
<a name="line55"></a>   * A map of action element uid/action event type pairs.
<a name="line56"></a>   * @type {goog.structs.Map}
<a name="line57"></a>   * @private
<a name="line58"></a>   */
<a name="line59"></a>  this.actionMap_ = new goog.structs.Map();
<a name="line60"></a>};
<a name="line61"></a>goog.inherits(goog.ui.OfflineStatusCard, goog.ui.Component);
<a name="line62"></a>
<a name="line63"></a>
<a name="line64"></a>/**
<a name="line65"></a> * Event types dispatched by the component.
<a name="line66"></a> * @enum {string}
<a name="line67"></a> */
<a name="line68"></a>goog.ui.OfflineStatusCard.EventType = {
<a name="line69"></a>  /** Dispatched when the user wants the card to be dismissed. */
<a name="line70"></a>  DISMISS: &#39;dismiss&#39;
<a name="line71"></a>};
<a name="line72"></a>
<a name="line73"></a>
<a name="line74"></a>/**
<a name="line75"></a> * Whether the component is dirty and requires an upate to its display.
<a name="line76"></a> * @type {boolean}
<a name="line77"></a> * @protected
<a name="line78"></a> */
<a name="line79"></a>goog.ui.OfflineStatusCard.prototype.dirty = false;
<a name="line80"></a>
<a name="line81"></a>
<a name="line82"></a>/**
<a name="line83"></a> * The status of the component.
<a name="line84"></a> * @type {goog.gears.StatusType}
<a name="line85"></a> * @private
<a name="line86"></a> */
<a name="line87"></a>goog.ui.OfflineStatusCard.prototype.status_ =
<a name="line88"></a>    goog.gears.StatusType.NOT_INSTALLED;
<a name="line89"></a>
<a name="line90"></a>
<a name="line91"></a>/**
<a name="line92"></a> * The element that holds the status message.
<a name="line93"></a> * @type {Element}
<a name="line94"></a> * @private
<a name="line95"></a> */
<a name="line96"></a>goog.ui.OfflineStatusCard.prototype.statusEl_ = null;
<a name="line97"></a>
<a name="line98"></a>
<a name="line99"></a>/**
<a name="line100"></a> * The element that, when clicked, performs the appropriate action (such as
<a name="line101"></a> * pausing synchronization).
<a name="line102"></a> * @type {Element}
<a name="line103"></a> * @private
<a name="line104"></a> */
<a name="line105"></a>goog.ui.OfflineStatusCard.prototype.actionEl_ = null;
<a name="line106"></a>
<a name="line107"></a>
<a name="line108"></a>/**
<a name="line109"></a> * The element that displays additional messaging.
<a name="line110"></a> * @type {Element}
<a name="line111"></a> * @private
<a name="line112"></a> */
<a name="line113"></a>goog.ui.OfflineStatusCard.prototype.messageEl_ = null;
<a name="line114"></a>
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * The element that holds the progress bar and progress status.
<a name="line118"></a> * @type {Element}
<a name="line119"></a> * @private
<a name="line120"></a> */
<a name="line121"></a>goog.ui.OfflineStatusCard.prototype.progressEl_ = null;
<a name="line122"></a>
<a name="line123"></a>
<a name="line124"></a>/**
<a name="line125"></a> * The element that holds the progress status.
<a name="line126"></a> * @type {Element}
<a name="line127"></a> * @private
<a name="line128"></a> */
<a name="line129"></a>goog.ui.OfflineStatusCard.prototype.progressStatusEl_ = null;
<a name="line130"></a>
<a name="line131"></a>
<a name="line132"></a>/**
<a name="line133"></a> * The element that holds the close button.
<a name="line134"></a> * @type {Element}
<a name="line135"></a> * @private
<a name="line136"></a> */
<a name="line137"></a>goog.ui.OfflineStatusCard.prototype.closeEl_ = null;
<a name="line138"></a>
<a name="line139"></a>
<a name="line140"></a>/**
<a name="line141"></a> * CSS class name for the element.
<a name="line142"></a> * @type {string}
<a name="line143"></a> * @private
<a name="line144"></a> */
<a name="line145"></a>goog.ui.OfflineStatusCard.prototype.className_ =
<a name="line146"></a>    goog.getCssName(&#39;goog-offlinestatuscard&#39;);
<a name="line147"></a>
<a name="line148"></a>
<a name="line149"></a>/**
<a name="line150"></a> * CSS class name for the shadow element.
<a name="line151"></a> * @type {string}
<a name="line152"></a> * @private
<a name="line153"></a> */
<a name="line154"></a>goog.ui.OfflineStatusCard.prototype.shadowClassName_ =
<a name="line155"></a>    goog.getCssName(&#39;goog-offlinestatuscard-shadow&#39;);
<a name="line156"></a>
<a name="line157"></a>
<a name="line158"></a>/**
<a name="line159"></a> * CSS class name for the content element.
<a name="line160"></a> * @type {string}
<a name="line161"></a> * @private
<a name="line162"></a> */
<a name="line163"></a>goog.ui.OfflineStatusCard.prototype.contentClassName_ =
<a name="line164"></a>    goog.getCssName(&#39;goog-offlinestatuscard-content&#39;);
<a name="line165"></a>
<a name="line166"></a>
<a name="line167"></a>/**
<a name="line168"></a> * CSS class name for the status element.
<a name="line169"></a> * @type {string}
<a name="line170"></a> * @private
<a name="line171"></a> */
<a name="line172"></a>goog.ui.OfflineStatusCard.prototype.statusClassName_ =
<a name="line173"></a>    goog.getCssName(&#39;goog-offlinestatuscard-status&#39;);
<a name="line174"></a>
<a name="line175"></a>
<a name="line176"></a>/**
<a name="line177"></a> * CSS class name for the action element.
<a name="line178"></a> * @type {string}
<a name="line179"></a> * @private
<a name="line180"></a> */
<a name="line181"></a>goog.ui.OfflineStatusCard.prototype.actionClassName_ =
<a name="line182"></a>    goog.getCssName(&#39;goog-offlinestatuscard-action&#39;);
<a name="line183"></a>
<a name="line184"></a>
<a name="line185"></a>/**
<a name="line186"></a> * CSS class name for each action item contained in the action element.
<a name="line187"></a> * @type {string}
<a name="line188"></a> * @private
<a name="line189"></a> */
<a name="line190"></a>goog.ui.OfflineStatusCard.prototype.actionItemClassName_ =
<a name="line191"></a>    goog.getCssName(&#39;goog-offlinestatuscard-action-item&#39;);
<a name="line192"></a>
<a name="line193"></a>
<a name="line194"></a>/**
<a name="line195"></a> * CSS class name for the last action item contained in the action element.
<a name="line196"></a> * @type {string}
<a name="line197"></a> * @private
<a name="line198"></a> */
<a name="line199"></a>goog.ui.OfflineStatusCard.prototype.lastActionItemClassName_ =
<a name="line200"></a>    goog.getCssName(&#39;goog-offlinestatuscard-action-item-last&#39;);
<a name="line201"></a>
<a name="line202"></a>
<a name="line203"></a>/**
<a name="line204"></a> * CSS class name for the message element.
<a name="line205"></a> * @type {string}
<a name="line206"></a> * @private
<a name="line207"></a> */
<a name="line208"></a>goog.ui.OfflineStatusCard.prototype.messageClassName_ =
<a name="line209"></a>    goog.getCssName(&#39;goog-offlinestatuscard-message&#39;);
<a name="line210"></a>
<a name="line211"></a>
<a name="line212"></a>/**
<a name="line213"></a> * CSS class name for the progress bar status element.
<a name="line214"></a> * @type {string}
<a name="line215"></a> * @private
<a name="line216"></a> */
<a name="line217"></a>goog.ui.OfflineStatusCard.prototype.progressBarStatusClassName_ =
<a name="line218"></a>    goog.getCssName(&#39;goog-offlinestatuscard-progressbarstatus&#39;);
<a name="line219"></a>
<a name="line220"></a>
<a name="line221"></a>/**
<a name="line222"></a> * CSS class name for the close card element.
<a name="line223"></a> * @type {string}
<a name="line224"></a> * @private
<a name="line225"></a> */
<a name="line226"></a>goog.ui.OfflineStatusCard.prototype.closeCardClassName_ =
<a name="line227"></a>    goog.getCssName(&#39;goog-offlinestatuscard-closecard&#39;);
<a name="line228"></a>
<a name="line229"></a>
<a name="line230"></a>/**
<a name="line231"></a> * Gets the progress bar.
<a name="line232"></a> * @return {goog.ui.ProgressBar} The progress bar.
<a name="line233"></a> */
<a name="line234"></a>goog.ui.OfflineStatusCard.prototype.getProgressBar = function() {
<a name="line235"></a>  return this.progressBar_;
<a name="line236"></a>};
<a name="line237"></a>
<a name="line238"></a>
<a name="line239"></a>/**
<a name="line240"></a> * Gets the status of the offline component of the app.
<a name="line241"></a> * @return {goog.gears.StatusType} The offline status.
<a name="line242"></a> */
<a name="line243"></a>goog.ui.OfflineStatusCard.prototype.getStatus = function() {
<a name="line244"></a>  return this.status_;
<a name="line245"></a>};
<a name="line246"></a>
<a name="line247"></a>
<a name="line248"></a>/**
<a name="line249"></a> * Sets the status of the offline component of the app.
<a name="line250"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line251"></a> */
<a name="line252"></a>goog.ui.OfflineStatusCard.prototype.setStatus = function(status) {
<a name="line253"></a>  if (this.status_ != status) {
<a name="line254"></a>    this.dirty = true;
<a name="line255"></a>  }
<a name="line256"></a>  this.status_ = status;
<a name="line257"></a>  if (this.isInDocument()) {
<a name="line258"></a>    this.update();
<a name="line259"></a>  }
<a name="line260"></a>};
<a name="line261"></a>
<a name="line262"></a>
<a name="line263"></a>/**
<a name="line264"></a> * Creates the initial DOM representation for the component.
<a name="line265"></a> * @override
<a name="line266"></a> */
<a name="line267"></a>goog.ui.OfflineStatusCard.prototype.createDom = function() {
<a name="line268"></a>  var dom = this.getDomHelper();
<a name="line269"></a>  this.setElementInternal(dom.createDom(&#39;div&#39;, this.className_,
<a name="line270"></a>      dom.createDom(&#39;div&#39;, this.shadowClassName_,
<a name="line271"></a>          dom.createDom(&#39;div&#39;, this.contentClassName_,
<a name="line272"></a>              this.closeEl_ = dom.createDom(&#39;div&#39;, this.closeCardClassName_),
<a name="line273"></a>              this.statusEl_ = dom.createDom(&#39;div&#39;, this.statusClassName_),
<a name="line274"></a>              this.progressEl_ = dom.createDom(&#39;div&#39;, null,
<a name="line275"></a>                  this.progressBarStatusEl_ =
<a name="line276"></a>                      dom.createDom(&#39;div&#39;, this.progressBarStatusClassName_)),
<a name="line277"></a>              this.actionEl_ = dom.createDom(&#39;div&#39;, this.actionClassName_),
<a name="line278"></a>              this.messageEl_ = dom.createDom(&#39;div&#39;,
<a name="line279"></a>                  this.messageClassName_)))));
<a name="line280"></a>
<a name="line281"></a>  // Create and append the DOM of the progress bar.
<a name="line282"></a>  this.progressBar_.createDom();
<a name="line283"></a>  dom.insertSiblingBefore(
<a name="line284"></a>      this.progressBar_.getElement(), this.progressBarStatusEl_);
<a name="line285"></a>
<a name="line286"></a>  this.createAdditionalDom();
<a name="line287"></a>
<a name="line288"></a>  this.update();
<a name="line289"></a>};
<a name="line290"></a>
<a name="line291"></a>
<a name="line292"></a>/** @override */
<a name="line293"></a>goog.ui.OfflineStatusCard.prototype.enterDocument = function() {
<a name="line294"></a>  goog.ui.OfflineStatusCard.superClass_.enterDocument.call(this);
<a name="line295"></a>
<a name="line296"></a>  // Listen for changes to the progress bar.
<a name="line297"></a>  var handler = this.getHandler();
<a name="line298"></a>  handler.listen(this.progressBar_, goog.ui.Component.EventType.CHANGE,
<a name="line299"></a>      this.handleProgressChange_);
<a name="line300"></a>
<a name="line301"></a>  // Listen for a click on the action element.
<a name="line302"></a>  handler.listen(
<a name="line303"></a>      this.actionEl_, goog.events.EventType.CLICK, this.handleActionClick_);
<a name="line304"></a>
<a name="line305"></a>  // Listen for the click on the close element.
<a name="line306"></a>  handler.listen(this.closeEl_, goog.events.EventType.CLICK, this.closePopup_);
<a name="line307"></a>
<a name="line308"></a>  // Update the component if it is dirty.
<a name="line309"></a>  if (this.dirty) {
<a name="line310"></a>    this.update();
<a name="line311"></a>  }
<a name="line312"></a>};
<a name="line313"></a>
<a name="line314"></a>
<a name="line315"></a>/**
<a name="line316"></a> * Allows subclasses to initialize additional DOM structures during createDom.
<a name="line317"></a> * @protected
<a name="line318"></a> */
<a name="line319"></a>goog.ui.OfflineStatusCard.prototype.createAdditionalDom = function() {
<a name="line320"></a>};
<a name="line321"></a>
<a name="line322"></a>
<a name="line323"></a>/**
<a name="line324"></a> * Sends an event to OfflineStatusComponent to dismiss the popup.
<a name="line325"></a> * @private
<a name="line326"></a> */
<a name="line327"></a>goog.ui.OfflineStatusCard.prototype.closePopup_ = function() {
<a name="line328"></a>  this.dispatchEvent(goog.ui.OfflineStatusCard.EventType.DISMISS);
<a name="line329"></a>};
<a name="line330"></a>
<a name="line331"></a>
<a name="line332"></a>/**
<a name="line333"></a> * Updates the display of the component.
<a name="line334"></a> */
<a name="line335"></a>goog.ui.OfflineStatusCard.prototype.update = function() {
<a name="line336"></a>  if (this.getElement()) {
<a name="line337"></a>    var status = this.getStatus();
<a name="line338"></a>    var dom = this.getDomHelper();
<a name="line339"></a>
<a name="line340"></a>    this.configureStatusElement(status);
<a name="line341"></a>    this.configureActionLinks(status);
<a name="line342"></a>    this.configureProgressElement(status);
<a name="line343"></a>
<a name="line344"></a>    // Configure the message element.
<a name="line345"></a>    var message = this.getAdditionalMessage(status);
<a name="line346"></a>    var messageEl = this.messageEl_;
<a name="line347"></a>    goog.style.showElement(messageEl, message);
<a name="line348"></a>    if (message) {
<a name="line349"></a>      dom.setTextContent(messageEl, message);
<a name="line350"></a>    }
<a name="line351"></a>
<a name="line352"></a>    // Clear the dirty state.
<a name="line353"></a>    this.dirty = false;
<a name="line354"></a>  }
<a name="line355"></a>};
<a name="line356"></a>
<a name="line357"></a>
<a name="line358"></a>/**
<a name="line359"></a> * Set the message to display in the status portion of the card.
<a name="line360"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line361"></a> */
<a name="line362"></a>goog.ui.OfflineStatusCard.prototype.configureStatusElement = function(status) {
<a name="line363"></a>  /**
<a name="line364"></a>   * @desc Tell the user whether they are online, offline, or syncing to
<a name="line365"></a>   *     Gears.
<a name="line366"></a>   */
<a name="line367"></a>  var MSG_OFFLINE_STATUS = goog.getMsg(
<a name="line368"></a>      &#39;Status: {$msg}&#39;, {&#39;msg&#39;: this.getStatusMessage(status)});
<a name="line369"></a>  this.getDomHelper().setTextContent(this.statusEl_, MSG_OFFLINE_STATUS);
<a name="line370"></a>};
<a name="line371"></a>
<a name="line372"></a>
<a name="line373"></a>/**
<a name="line374"></a> * Set the action element to show correct action(s) for a particular status.
<a name="line375"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line376"></a> */
<a name="line377"></a>goog.ui.OfflineStatusCard.prototype.configureActionLinks = function(status) {
<a name="line378"></a>  // Configure the action element.
<a name="line379"></a>  var actions = this.getActions(status);
<a name="line380"></a>  goog.dom.removeChildren(this.actionEl_);
<a name="line381"></a>  this.actionMap_.clear();
<a name="line382"></a>
<a name="line383"></a>  if (actions) {
<a name="line384"></a>    var lastIdx = actions.length - 1;
<a name="line385"></a>    for (var i = 0; i &lt;= lastIdx; i++) {
<a name="line386"></a>      // Ensure there is no padding to the right of the last action link.
<a name="line387"></a>      this.createLinkNode_(actions[i], i == lastIdx ?
<a name="line388"></a>          this.lastActionItemClassName_ : this.actionItemClassName_);
<a name="line389"></a>    }
<a name="line390"></a>  }
<a name="line391"></a>};
<a name="line392"></a>
<a name="line393"></a>
<a name="line394"></a>/**
<a name="line395"></a> * Creates an action link element and styles it.
<a name="line396"></a> * @param {Object} action An action object with message and event type.
<a name="line397"></a> * @param {string} className The css class name to style the link with.
<a name="line398"></a> * @private
<a name="line399"></a> */
<a name="line400"></a>goog.ui.OfflineStatusCard.prototype.createLinkNode_ = function(
<a name="line401"></a>    action, className) {
<a name="line402"></a>  var actionEl = this.actionEl_;
<a name="line403"></a>  var dom = this.getDomHelper();
<a name="line404"></a>  var a = dom.createDom(&#39;span&#39;, className);
<a name="line405"></a>  dom.appendChild(actionEl, a);
<a name="line406"></a>  // A text node is needed here in order for links to wrap.
<a name="line407"></a>  dom.appendChild(actionEl, dom.createTextNode(&#39; &#39;));
<a name="line408"></a>  this.actionMap_.set(goog.getUid(a), action.eventType);
<a name="line409"></a>  goog.style.showElement(a, true);
<a name="line410"></a>  dom.setTextContent(a, action.message);
<a name="line411"></a>};
<a name="line412"></a>
<a name="line413"></a>
<a name="line414"></a>/**
<a name="line415"></a> * Configure the progress bar element.
<a name="line416"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line417"></a> */
<a name="line418"></a>goog.ui.OfflineStatusCard.prototype.configureProgressElement =
<a name="line419"></a>    function(status) {
<a name="line420"></a>  var showProgress = this.shouldShowProgressBar(status);
<a name="line421"></a>  goog.style.showElement(this.progressEl_, showProgress);
<a name="line422"></a>  if (showProgress) {
<a name="line423"></a>    this.updateProgressStatus();
<a name="line424"></a>  }
<a name="line425"></a>};
<a name="line426"></a>
<a name="line427"></a>
<a name="line428"></a>/**
<a name="line429"></a> * Returns true if we want to display a progress bar.
<a name="line430"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line431"></a> * @return {boolean} Whether we want to display a progress bar.
<a name="line432"></a> */
<a name="line433"></a>goog.ui.OfflineStatusCard.prototype.shouldShowProgressBar = function(status) {
<a name="line434"></a>  return status == goog.gears.StatusType.SYNCING ||
<a name="line435"></a>      status == goog.gears.StatusType.CAPTURING;
<a name="line436"></a>};
<a name="line437"></a>
<a name="line438"></a>
<a name="line439"></a>/**
<a name="line440"></a> * Handles a CHANGE event of the progress bar. Updates the status.
<a name="line441"></a> * @param {goog.events.Event} e The event.
<a name="line442"></a> * @private
<a name="line443"></a> */
<a name="line444"></a>goog.ui.OfflineStatusCard.prototype.handleProgressChange_ = function(e) {
<a name="line445"></a>  this.updateProgressStatus();
<a name="line446"></a>};
<a name="line447"></a>
<a name="line448"></a>
<a name="line449"></a>/**
<a name="line450"></a> * Handles a CLICK event on the action element. Dispatches the appropriate
<a name="line451"></a> * action event type.
<a name="line452"></a> * @param {goog.events.BrowserEvent} e The event.
<a name="line453"></a> * @private
<a name="line454"></a> */
<a name="line455"></a>goog.ui.OfflineStatusCard.prototype.handleActionClick_ = function(e) {
<a name="line456"></a>  var actionEventType = /** @type {string} */ (this.actionMap_.get(
<a name="line457"></a>      goog.getUid(e.target)));
<a name="line458"></a>  if (actionEventType) {
<a name="line459"></a>    this.dispatchEvent(actionEventType);
<a name="line460"></a>  }
<a name="line461"></a>};
<a name="line462"></a>
<a name="line463"></a>
<a name="line464"></a>/**
<a name="line465"></a> * Updates the status of the progress bar.
<a name="line466"></a> * @protected
<a name="line467"></a> */
<a name="line468"></a>goog.ui.OfflineStatusCard.prototype.updateProgressStatus = function() {
<a name="line469"></a>  this.getDomHelper().setTextContent(
<a name="line470"></a>      this.progressBarStatusEl_, this.getProgressStatusMessage());
<a name="line471"></a>};
<a name="line472"></a>
<a name="line473"></a>
<a name="line474"></a>/**
<a name="line475"></a> * Gets the status message for the progress bar.
<a name="line476"></a> * @return {string} The status message for the progress bar.
<a name="line477"></a> */
<a name="line478"></a>goog.ui.OfflineStatusCard.prototype.getProgressStatusMessage = function() {
<a name="line479"></a>  var pb = this.progressBar_;
<a name="line480"></a>  var percentValue = Math.round((pb.getValue() - pb.getMinimum()) /
<a name="line481"></a>                                (pb.getMaximum() - pb.getMinimum()) * 100);
<a name="line482"></a>  /** @desc The percent complete status of the syncing. */
<a name="line483"></a>  var MSG_OFFLINE_PERCENT_COMPLETE = goog.getMsg(
<a name="line484"></a>      &#39;{$num}% complete.&#39;, {&#39;num&#39;: percentValue});
<a name="line485"></a>  return MSG_OFFLINE_PERCENT_COMPLETE;
<a name="line486"></a>};
<a name="line487"></a>
<a name="line488"></a>
<a name="line489"></a>/**
<a name="line490"></a> * Gets the status message for the given status.
<a name="line491"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line492"></a> * @return {string} The status message.
<a name="line493"></a> */
<a name="line494"></a>goog.ui.OfflineStatusCard.prototype.getStatusMessage = function(status) {
<a name="line495"></a>  var message = &#39;&#39;;
<a name="line496"></a>
<a name="line497"></a>  switch (status) {
<a name="line498"></a>    case goog.gears.StatusType.OFFLINE:
<a name="line499"></a>      /** @desc Status shown when the app is offline. */
<a name="line500"></a>      var MSG_OFFLINE_STATUS_OFFLINE_MESSAGE = goog.getMsg(
<a name="line501"></a>          &#39;Offline. No connection available.&#39;);
<a name="line502"></a>      message = MSG_OFFLINE_STATUS_OFFLINE_MESSAGE;
<a name="line503"></a>      break;
<a name="line504"></a>    case goog.gears.StatusType.ONLINE:
<a name="line505"></a>      /** @desc Status shown when the app is online. */
<a name="line506"></a>      var MSG_OFFLINE_STATUS_ONLINE_MESSAGE = goog.getMsg(&#39;Online&#39;);
<a name="line507"></a>      message = MSG_OFFLINE_STATUS_ONLINE_MESSAGE;
<a name="line508"></a>      break;
<a name="line509"></a>    case goog.gears.StatusType.SYNCING:
<a name="line510"></a>      /** @desc Status shown when the app is synchronizing. */
<a name="line511"></a>      var MSG_OFFLINE_STATUS_SYNCING_MESSAGE = goog.getMsg(&#39;Synchronizing...&#39;);
<a name="line512"></a>      message = MSG_OFFLINE_STATUS_SYNCING_MESSAGE;
<a name="line513"></a>      break;
<a name="line514"></a>    case goog.gears.StatusType.CAPTURING:
<a name="line515"></a>      /** @desc Status shown when the app is capturing resources. */
<a name="line516"></a>      var MSG_OFFLINE_STATUS_CAPTURING_MESSAGE = goog.getMsg(
<a name="line517"></a>          &#39;Updating software...&#39;);
<a name="line518"></a>      message = MSG_OFFLINE_STATUS_CAPTURING_MESSAGE;
<a name="line519"></a>      break;
<a name="line520"></a>    case goog.gears.StatusType.ERROR:
<a name="line521"></a>      /** @desc Status shown when an error has occured. */
<a name="line522"></a>      var MSG_OFFLINE_STATUS_ERROR_MESSAGE = goog.getMsg(
<a name="line523"></a>          &#39;Errors have been found.&#39;);
<a name="line524"></a>      message = MSG_OFFLINE_STATUS_ERROR_MESSAGE;
<a name="line525"></a>      break;
<a name="line526"></a>    default:
<a name="line527"></a>      break;
<a name="line528"></a>  }
<a name="line529"></a>  return message;
<a name="line530"></a>};
<a name="line531"></a>
<a name="line532"></a>
<a name="line533"></a>/**
<a name="line534"></a> * Gets the action to display for the given status.
<a name="line535"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line536"></a> * @return {Array.&lt;Object&gt;?} An array of action objects to display.
<a name="line537"></a> */
<a name="line538"></a>goog.ui.OfflineStatusCard.prototype.getActions = function(status) {
<a name="line539"></a>  return null;
<a name="line540"></a>};
<a name="line541"></a>
<a name="line542"></a>
<a name="line543"></a>/**
<a name="line544"></a> * Creates an action object containing a message for the action and event
<a name="line545"></a> * type to dispatch if the action occurs.
<a name="line546"></a> * @param {string} actionMessage The action message.
<a name="line547"></a> * @param {string} actionEventType The action event type.
<a name="line548"></a> * @return {Object} An object containing message and eventType properties.
<a name="line549"></a> */
<a name="line550"></a>goog.ui.OfflineStatusCard.prototype.createActionObject = function(
<a name="line551"></a>    actionMessage, actionEventType) {
<a name="line552"></a>  return {message: actionMessage, eventType: actionEventType};
<a name="line553"></a>};
<a name="line554"></a>
<a name="line555"></a>
<a name="line556"></a>/**
<a name="line557"></a> * Gets the additional message to display for the given status.
<a name="line558"></a> * @param {goog.gears.StatusType} status The offline status.
<a name="line559"></a> * @return {string} The additional message.
<a name="line560"></a> */
<a name="line561"></a>goog.ui.OfflineStatusCard.prototype.getAdditionalMessage = function(status) {
<a name="line562"></a>  return &#39;&#39;;
<a name="line563"></a>};
<a name="line564"></a>
<a name="line565"></a>
<a name="line566"></a>/** @override */
<a name="line567"></a>goog.ui.OfflineStatusCard.prototype.disposeInternal = function() {
<a name="line568"></a>  goog.ui.OfflineStatusCard.superClass_.disposeInternal.call(this);
<a name="line569"></a>
<a name="line570"></a>  this.progressBar_.dispose();
<a name="line571"></a>  this.progressBar_ = null;
<a name="line572"></a>
<a name="line573"></a>  this.actionMap_.clear();
<a name="line574"></a>  this.actionMap_ = null;
<a name="line575"></a>
<a name="line576"></a>  this.statusEl_ = null;
<a name="line577"></a>  this.actionEl_ = null;
<a name="line578"></a>  this.messageEl_ = null;
<a name="line579"></a>  this.progressEl_ = null;
<a name="line580"></a>  this.progressStatusEl_ = null;
<a name="line581"></a>};
</pre>


</body>
</html>
